package com.yang.springcloudalibaba.controller;

import com.yang.springcloud.pojo.Student;
import com.yang.springcloudalibaba.service.StudentServiceImp;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
public class StudentController {

    @Autowired
    private StudentServiceImp ssi;

    @PostMapping("/insert")
    public Map<String, Object> addStudent(@RequestBody Student s) {
        System.out.println(s.getId()+ " " + s.getName() + " " + s.getBirth() + " " + s.getSex());
        return ssi.addStudent(s);
    }

    @PostMapping("/delete")
    public Map<String, Object> delereStudent(@RequestBody String name) {
        System.out.println(name);
        return ssi.delereStudent(name);
    }

    @PostMapping("/update")
    public Map<String, Object> updateStudent(@RequestBody Student s) {
        return ssi.updateStudent(s);
    }

    @GetMapping("/query")
    public List<Student> queryAll() {
        return ssi.queryAll();
    }

    @GetMapping("/queryById/{passid}")
    public Student queryById(@PathVariable("passid") String passid){
        System.out.println("7071 执行了");
        return ssi.queryById(passid);
    }
}
